﻿/*
 * Copyright (c) 2011 http://DesignBased.NET 
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the 
 * Software  * without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the 
 * Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
 * 
 */

using System.ComponentModel;
using Newtonsoft.Json;

namespace T163.Open.Api.Model
{
    /// <summary>
    /// 微博
    /// </summary>
    [JsonObject(MemberSerialization.OptIn)]
    public class Statues : INotifyPropertyChanged
    {
        #region private fields

        private string _id;
        private string _source;
        private string _flag = "normal"; // normal,retweet, reply, deleted
        private Users _user;
        private string _createdAt;        
        private string _text;
        private string _inReplyToStausId;
        private string _inReplyToUserId;
        private string _inReplyToScreenName;
        private int _retweetCount;
        private int _commentsCount;
        private string _favorited_at;
        private string _inReplyToStatusText;
        private string _inReplyToUserName;
        private bool _favorited;
        private string _cursorId;
        private string _rootInReplyToStatusId;
        private bool _isRetweetByUser;
        private string _retweetUserId;
        private string _retweetUserName;
        private string _retweetUserScreenName;
        private string _retweetCreatedAt;
        private string _rootInReplyToUserId;
        private string _rootInReplyToScreenName;
        private string _rootInReplyToUserName;
        private string _rootInReplyToStatusText;

        #endregion

        /// <summary>
        /// 创建时间
        /// </summary>
        [JsonProperty("created_at")]
        public string CreatedAt
        {
            get { return _createdAt; }
            set
            {
                if (value != _createdAt)
                {
                    _createdAt = value;
                }
            }
        }

        /// <summary>
        /// 微博ID
        /// </summary>
        [JsonProperty("id")]
        public string ID
        {
            get { return _id; }
            set
            {
                if (value != _id)
                {
                    _id = value;
                    OnPropertyChanged("ID");
                }
            }
        }

        /// <summary>
        /// 微博内容
        /// </summary>
        [JsonProperty("text")]
        public string Text
        {
            get { return _text; }
            set
            {
                if (value != _text)
                {
                    _text = value;
                    OnPropertyChanged("Text");
                }
            }
        }

        /// <summary>
        /// 微博来源
        /// </summary>
        [JsonProperty("source")]
        public string Source
        {
            get { return _source; }
            set
            {
                if (value != _source)
                {
                    _source = value;
                    OnPropertyChanged("Source");
                }
            }
        }

        /// <summary>
        /// 标志 normal, retweet, reply, deleted
        /// </summary>
        [JsonProperty("flag")]
        public string Flag
        {
            get
            {
                return _flag;
            }
            set
            {
                if (_flag != value)
                {
                    _flag = value;
                    OnPropertyChanged("Flag");
                }
            }
        }

        /// <summary>
        /// 是否收藏
        /// </summary>
        [JsonProperty("favorited")]
        public bool Favorited
        {
            get { return _favorited; }
            set
            {
                if (value != _favorited)
                {
                    _favorited = value;
                    OnPropertyChanged("Favorited");
                }
            }
        }

        /// <summary>
        /// 回复id
        /// </summary>
        [JsonProperty("in_reply_to_status_id")]
        public string InReplyToStatusID
        {
            get { return _inReplyToStausId; }
            set
            {
                if (value != _inReplyToStausId)
                {
                    _inReplyToStausId = value;
                    OnPropertyChanged("InReplyToStatusID");
                }
            }
        }

        /// <summary>
        /// 回复人id
        /// </summary>
        [JsonProperty("in_reply_to_user_id")]
        public string InReplyToUserID
        {
            get { return _inReplyToUserId; }
            set
            {
                if (value != _inReplyToUserId)
                {
                    _inReplyToUserId = value;
                    OnPropertyChanged("InReplyToUserID");
                }
            }
        }

        /// <summary>
        /// 回复人昵称
        /// </summary>
        [JsonProperty("in_reply_to_screen_name")]
        public string InReplyToScreenName
        {
            get { return _inReplyToScreenName; }
            set
            {
                if (value != _inReplyToScreenName)
                {
                    _inReplyToScreenName = value;
                    OnPropertyChanged("InReplyToScreenName");
                }
            }
        }

        /// <summary>
        /// 作者信息
        /// </summary>
        [JsonProperty("user")]
        public Users User
        {
            get { return _user; }
            set
            {
                if (value != _user)
                {
                    _user = value;
                    OnPropertyChanged("User");
                }
            }
        }

        /// <summary>
        /// 转发次数
        /// </summary>
        [JsonProperty("retweet_count")]
        public int RetweetCount
        {
            get
            {
                return this._retweetCount;
            }
            set
            {
                if (value != _retweetCount)
                {
                    _retweetCount = value;
                    OnPropertyChanged("RetweetCount");
                }
            }
        }

        /// <summary>
        /// 评论次数
        /// </summary>
        [JsonProperty("comments_count")]
        public int CommentsCount
        {
            get
            {
                return this._commentsCount;
            }
            set
            {
                if (value != this._commentsCount)
                {
                    this._commentsCount = value;
                    OnPropertyChanged("CommentsCount");
                }
            }
        }

        /// <summary>
        /// 收藏时间，未收藏则为null
        /// </summary>
        [JsonProperty("favorited_at")]
        public string FavoritedAt
        {
            get
            {
                    return _favorited_at;
            }
            set
            {
                if (_favorited_at != value)
                {
                    _favorited_at = value;
                    OnPropertyChanged("FavoritedAt");
                }
            }
        }

        /// <summary>
        /// 回复的微博正文
        /// </summary>
        [JsonProperty("in_reply_to_status_text")]
        public string InReplyToStatusText
        {
            get
            {
                return _inReplyToStatusText;
            }
            set
            {
                if (_inReplyToStatusText != value)
                {
                    _inReplyToStatusText = value;
                    OnPropertyChanged("InReplyToStatusText");
                }
            }
        }

        /// <summary>
        /// 回复微博的作者昵称
        /// </summary>
        [JsonProperty("in_reply_to_user_name")]
        public string InReplyToUserName
        {
            get
            {
                return _inReplyToUserName;
            }
            set
            {
                if (_inReplyToUserName != value)
                {
                    _inReplyToUserName = value;
                    OnPropertyChanged("InReplyToUserName");
                }
            }
        }
        
        /// <summary>
        /// 分布游标
        /// </summary>
        [JsonProperty("cursor_id")]
        public string CursorId
        {
            get
            {
                return _cursorId;
            }
            set
            {
                if (_cursorId != value)
                {
                    _cursorId = value;
                    OnPropertyChanged("CursorId");
                }
            }
        }

        /// <summary>
        /// 整个对话中根微博id
        /// </summary>
        [JsonProperty("root_in_reply_to_status_id")]
        public string RootInReplyToStatusId
        {
            get
            {
                return _rootInReplyToStatusId;
            }
            set
            {
                if (_rootInReplyToStatusId != value)
                {
                    _rootInReplyToStatusId = value;
                    OnPropertyChanged("RootInReplyToStatusId");
                }
            }
        }

        /// <summary>
        /// 是否被其他用户转发
        /// </summary>
        [JsonProperty("is_retweet_by_user")]
        public bool IsRetweetByUser
        {
            get
            {
                return _isRetweetByUser;
            }
            set
            {
                if (_isRetweetByUser != value)
                {
                    _isRetweetByUser = value;
                    OnPropertyChanged("IsRetweetByUser");
                }
            }
        }

        /// <summary>
        /// 第一个转发用户id
        /// </summary>
        [JsonProperty("retweet_user_id")]
        public string RetweetUserId
        {
            get
            {
                return _retweetUserId;
            }
            set
            {
                if (_retweetUserId != value)
                {
                    _retweetUserId = value;
                    OnPropertyChanged("RetweetUserId");
                }
            }
        }

        /// <summary>
        /// 转发用户的昵称
        /// </summary>
        [JsonProperty("retweet_user_name")]
        public string RetweetUserName
        {
            get
            {
                return _retweetUserName;
            }
            set
            {
                if (_retweetUserName != value)
                {
                    _retweetUserName = value;
                    OnPropertyChanged("RetweetUserName");
                }
            }
        }

        /// <summary>
        /// 转发用户个性网址
        /// </summary>
        [JsonProperty("retweet_user_screen_name")]
        public string RetweetUserScreenName
        {
            get
            {
                return _retweetUserScreenName;
            }
            set
            {
                if (_retweetUserScreenName != value)
                {
                    _retweetUserScreenName = value;
                    OnPropertyChanged("RetweetUserScreenName");
                }
            }
        }

        /// <summary>
        /// 转发时间
        /// </summary>
        [JsonProperty("RetweetCreatedAt")]
        public string RetweetCreatedAt
        {
            get
            {
                return _retweetCreatedAt;
            }
            set
            {
                if (_retweetCreatedAt != value)
                {
                    _retweetCreatedAt = value;
                    OnPropertyChanged("RetweetCreatedAt");
                }
            }
        }

        /// <summary>
        /// 微博原文作者
        /// </summary>
        [JsonProperty("root_in_reply_to_user_id")]
        public string RootInReplyToUserId
        {
            get
            {
                return _rootInReplyToUserId;
            }
            set
            {
                if (value != _rootInReplyToUserId)
                {
                    _rootInReplyToUserId = value;
                    OnPropertyChanged("RootInReplyToUserId");
                }
            }
        }
        
        /// <summary>
        /// 微博原文作者screen_name
        /// </summary>
        [JsonProperty("root_in_reply_to_screen_name")]
        public string RootInReplyToScreenName
        {
            get
            {
                return _rootInReplyToScreenName;
            }
            set
            {
                if (_rootInReplyToScreenName != value)
                {
                    _rootInReplyToScreenName = value;
                    OnPropertyChanged("RootInReplyToScreenName");
                }
            }
        }


        /// <summary>
        /// 微博原文作者昵称
        /// </summary>
        [JsonProperty("root_in_reply_to_user_name")]
        public string RootInReplyToUserName
        {
            get
            {
               return  _rootInReplyToUserName;
            }
            set
            {
                if (_rootInReplyToUserName != value)
                {
                    _rootInReplyToUserName = value;
                    OnPropertyChanged("RootInReplyToUserName");
                }
            }
        }
        
        /// <summary>
        /// 微博原文内容
        /// </summary>
        [JsonProperty("root_in_reply_to_status_text")]
        public string RootInReplyToStatusText
        {
            get
            {
                return _rootInReplyToStatusText;
            }
            set
            {
                if (_rootInReplyToStatusText != value)
                {
                    _rootInReplyToStatusText = value;
                    OnPropertyChanged("RootInReplyToStatusText");
                }
            }
        }

        public override bool Equals(object obj)
        {
            Statues other = obj as Statues;
            if (other == null)
                return false;

            return other.ID.Equals(this.ID);
        }

        public bool Equals(Statues status)
        {
            if (status == null)
                return false;

            return this.ID.Equals(status.ID);
        }

        public override int GetHashCode()
        {
            return this.ID.GetHashCode();
        }

        public override string ToString()
        {
            return string.IsNullOrEmpty(this.Text) ? string.Empty : this.Text;
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public virtual void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
